package com.local.dao;

import com.local.pojo.Department;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @author lou ke
 * @version 1.0
 * @since 2020/4/17 13:16
 */

// 部门 dao
@Repository
public class DepartmentDao {

    // 模拟数据中的数据
    private static Map<Integer, Department> departments = null;

    static {
        departments = new HashMap<Integer, Department>();  // 创建一个部门表

        departments.put(101, new Department(101, "教学部"));
        departments.put(102, new Department(102, "市场部"));
        departments.put(103, new Department(103, "文学部"));
        departments.put(104, new Department(104, "教研部"));
        departments.put(105, new Department(105, "体育部"));
    }


    // 查询所有部门信息
    public Collection<Department> getDepartment() {
        return departments.values();
    }

    // 根据 id 得到部门
    public Department getDepartmentById(Integer id) {
        return departments.get(id);
    }


}
